const express = require('express')
const app = express()
const { sleep } = require('./tools')
const port = 3000

app.get('/', (req, res) => {
  // res.send('Hello World!')
	res.type = 'text/html'
  res.write('loading...<br>')
  return sleep(2000).then(function() {
    res.write(`timer: 2000ms<br>`)
    return sleep(5000)
  })
  .then(function() {
    res.write(`timer: 5000ms<br>`)
  }).then(function() {
    res.end()
  })
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})